
public class Ex1 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		double a ,b ,c ,delta ,alpha ,beta ,tmp ,tmpb;
		int x;
		x = MyConsole.readInt("Please choose an option: 0)exit program , 1)calculate:");
		while (x==1){			  
			System.out.println("aX^2+bX+c=0: enter a,b,c");
			a = MyConsole.readDouble("Enter Value for a:");
			b = MyConsole.readDouble("Enter Value for b:");
			c = MyConsole.readDouble("Enter Value for c:");
			{
				if ((a==0)&&(b==0)&&(c==0)){

					System.out.println(a+"x^2+"+b+"x"+"+"+c+"=0 is a true argument 0=0");
				}

				else if ((a==0)&&(b!=0)&&(c!=0)){
					tmp=((c*(-1))/b);
					System.out.println("X="+tmp);

				}
				else if	((a!=0)&&(b==0)&&(c!=0)){
				    tmp=((-c)/a);
				    if (tmp<0){System.out.println("Error, No Real Roots!");}
				    else {
				    	tmpb=Math.sqrt(tmp);
				    
					System.out.println("X1="+tmpb+"X2="+(tmpb*(-1))); 
					}
				}
				else if((a==0)&&(b==0)&&(c!=0)) 
				{
					System.out.println("Error! " +c+"=0 is a false argument");

				}
				else if (a!=0 && b==0 && c==0){
					System.out.println("X="+(0/a));
				}
				
				else {

					delta = (b*b-4*c*a);
					if (delta<0){
						System.out.println("Error no actual root!");}
					else {
						alpha = (-b+(Math.sqrt(delta)))/(2*a) ;
						beta = (-b-(Math.sqrt(delta)))/(2*a) ;
						System.out.println(a+"x^2"+b+"x"+c+"=0");



						if (alpha==0&&beta==0){ 
							System.out.println("Any possible answer 0=0 , trivial!");


						}
						else if (alpha==beta){
							System.out.println("X1=X2="+alpha);
						}
						else System.out.println("X1="+alpha+", X2="+beta);

					}

				}


			}
			x = MyConsole.readInt("Please choose an option: 0)exit program , 1)calculate:");
		}

		System.out.println("Goodbye!");

	}
}

